package com.zyz.I_多线程.线程池.ScheduledThreadPool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author: vick
 * @Date: 2025/3/24
 * @Description:
 * @version: 1.0
 */
public class Test {
    public static void main(String[] args) {
        //创建一个线程池，它可安排在给定延迟后运行命令或者定期地执行。
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2);

        Demo demo1 = new Demo();
        scheduledExecutorService.execute(demo1);

        Demo demo2 = new Demo();
        scheduledExecutorService.schedule(demo2, 3000, TimeUnit.MILLISECONDS);

        scheduledExecutorService.shutdown();
    }
}
